#include <cstdlib>
#include <iostream>
#include <cstring>
#include <boost/asio.hpp>
using boost::asio::ip::udp;
enum { max_length = 1024 };


int main(int argc, char** argv) {
	try {
		boost::asio::io_context io_context;
		udp::socket s(io_context, udp::endpoint(udp::v4(), 0));

		udp::resolver resolver(io_context);
		auto endpoints = resolver.resolve(udp::v4(), "", "10089");
		std::cout << "Enter message: ";
		char request[max_length];
		std::cin.getline(request, max_length);
		size_t request_length = std::strlen(request);
		s.send_to(boost::asio::buffer(request, request_length), *endpoints.begin());
		char reply[max_length];
		udp::endpoint epserver;
		size_t reply_length = s.receive_from(boost::asio::buffer(reply, max_length), epserver);
		std::cout << "Reply is";
		std::cout.write(reply, reply_length);
		std::cout << "\n";
	}
	catch (std::exception &e) {
		std::cerr << "Exception" << e.what() << "\n";
	}
	return 0;
}